<!-- 专门给 webview 跳转小程序内页面 -->

<script lang="ts" setup>
import { onLoad } from '@dcloudio/uni-app'
import { object as zobject, string as zstring } from 'zod'

onLoad(async (query) => {
  const zparse = zobject({
    path: zstring().regex(/^.+$/).transform(decodeURIComponent),
  }).safeParse(query)
  if (!zparse.success) {
    return
  }

  // if (navigator.userAgent.includes('AliApp')) {
  //   const script = document.createElement('script')
  //   script.src = 'https://appx/web-view.min.js'
  //   document.head.appendChild(script)

  //   script.onload = () => {
  //     my.redirectTo({
  //       url: `/pages/${zparse.data.path}`,
  //     })
  //   }
  // }

  setTimeout(() => {
    my.redirectTo({
      url: `/pages/${zparse.data.path}`,
    })
  }, 500)
})
</script>

<template>
  <view></view>
</template>

<style lang="less" scoped></style>
